package org.alex.sample.dao.Impl;

import java.util.Iterator;
import java.util.List;

import org.alex.sample.dao.LoginDAO;
import org.alex.sample.model.User;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional
public class LoginDAOImpl extends BaseHibernateDAO<User> implements LoginDAO {

	@Override
	public List<User> findUserByUserName(String userName) throws Exception {
		Query hql = this.createSqlQuery("from User where user_name='" + userName + "'");
		List<User> userList = this.find(hql.getQueryString());
		return userList;
	}
	
	@Override
	public Iterator<User> iterate(String queryString, Object[] values) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void updateUserLoginFailCount(User user) throws Exception {
		this.update(user);
	}

	@Override
	public void uppdateUserLastLockTime(User user) throws Exception {
		this.update(user);
	}

}
